import java.util.Stack;

class Solution2 {
    public int evalRPN(String[] tokens) {
        Stack<Integer>st =new Stack<>();
        Stack<String>stc=new Stack<>();
        for (int i = 0; i < tokens.length; i++) {
         if(tokens[i].equals("*")||tokens[i].equals("+")||tokens[i].equals("-")||tokens[i].equals("/")){
             int right=st.pop();
             int left=st.pop();
             switch(tokens[i]){
                 case "+":
                     st.push(left + right);
                     break;
                 case "-":
                     st.push(left - right);
                     break;
                 case "*":
                     st.push(left * right);
                     break;
                 case "/":
                     st.push(left / right);
                     break;
             }

         }else{
             st.push(Integer.valueOf(tokens[i]));
         }

        }
        return st.peek();


        

    }
}